package org.studiox.graph.common.exception;

public enum GraphExceptionCode {
  CONFIG_FILE_NOT_EXIST("GE0001", "图库配置文件不存在，请仔细检查!"),

  CONFIG_PREFIX_NOT_EXIST("GE0002", "图库配置项前缀不存在，请仔细检查!"),

  CONFIG_FORMAT_NOT_CORRECT("GE0003", "图库配置文件格式不正确，请仔细检查!"),

  JANUS_GRAPH_EXCEPTION("GE0004", "JanusGraphs实例方法调用异常，请详细查看异常栈等日志信息!");

  private String code;

  private String desc;

  GraphExceptionCode(String code, String desc) {
    this.setCode(code);
    this.setDesc(desc);
  }

  public String getCode() {
    return code;
  }

  public void setCode(String code) {
    this.code = code;
  }

  public String getDesc() {
    return desc;
  }

  public void setDesc(String desc) {
    this.desc = desc;
  }

  public String getExceptionMsg() {
    return "Graph Exception code='" + getCode() + "' and desc='" + getDesc() + "'.";
  }

  public String getExceptionMsg(String detailMsg) {
    return "Graph Exception code='"
        + getCode()
        + "' and desc='"
        + getDesc()
        + "', with the detail msg='"
        + detailMsg
        + "'.";
  }

  @Override
  public String toString() {
    final StringBuffer stringBuffer = new StringBuffer("GraphExceptionCode{");
    stringBuffer.append("code='").append(code).append('\'');
    stringBuffer.append(", desc='").append(desc).append('\'');
    stringBuffer.append('}');
    return stringBuffer.toString();
  }
}
